<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
$oFile = '../plugins/ucenter/config.inc.php';
if(!is_file($oFile)) die('您的系统没有安装 UCenter 插件，<a href="UCenterSet.php">重新检测</a> 或 <a href="http://www.songcms.com/uploadfile/Download/plugins/UCenter1.5.0.rar">下载安装</a> >>>');
if(!empty($_POST)){
	$xText = "<?php\r\n";
	$xText .= "define('UC_ENABLED',{$_POST['UC_ENABLED']});\r\n";
	$xText .= "define('UC_CONNECT', '{$_POST['UC_CONNECT']}');\r\n";
	$xText .= "define('UC_DBHOST', '{$_POST['UC_DBHOST']}');\r\n";
	$xText .= "define('UC_DBUSER', '{$_POST['UC_DBUSER']}');\r\n";
	$xText .= "define('UC_DBPW', '{$_POST['UC_DBPW']}');\r\n";
	$xText .= "define('UC_DBNAME', '{$_POST['UC_DBNAME']}');\r\n";
	$xText .= "define('UC_DBCHARSET', 'utf8');\r\n";
	$xText .= "define('UC_DBTABLEPRE', '{$_POST['UC_DBTABLEPRE']}');\r\n";
	$xText .= "define('UC_KEY', '{$_POST['UC_KEY']}');\r\n";
	$xText .= "define('UC_API', '{$_POST['UC_API']}');\r\n";
	$xText .= "define('UC_CHARSET', 'utf8');\r\n";
	$xText .= "define('UC_IP', '{$_POST['UC_IP']}');\r\n";
	$xText .= "define('UC_APPID', {$_POST['UC_APPID']});\r\n";
	
	$xText .= "\r\n";
	
	$xText .= '$dbhost = \''.$dbhost.'\';'."\r\n";
	$xText .= '$dbuser = \''.$dbuser.'\';'."\r\n";
	$xText .= '$dbpw = \''.$dbpass.'\';'."\r\n";
	$xText .= '$dbname = \''.$dbname.'\';'."\r\n";
	$xText .= '$pconnect = 0;'."\r\n";
	$xText .= '$tablepre = \''.$dbprefix.'\';'."\r\n";
	$xText .= '$dbcharset = \'utf8\';'."\r\n";
	$xText .= '$cookiedomain = \'\';'."\r\n";
	$xText .= '$cookiepath = \'/\';'."\r\n";
	$xText .= '?>';

	if(@file_put_contents($oFile,$xText)){
		AdminLog(1,$Lang,'修改UCenter设置，结果：操作成功！'); 
		MsgBox (1,"UCenter设置修改成功。",1);
	} else {
		AdminLog(1,$Lang,'修改UCenter设置，结果：操作失败！'); 
		MsgBox (1,"修改失败，无法写入配置信息： {$oFile}",'1');
	}	
}
include_once($oFile);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
	<form id="form1" name="form1" method="post" action="">
	<tr>
	<td colspan="3" align="center" class="Main_Title">UCenter设置</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">UCenter同步通讯：</td>
	<td>
		<input name="UC_ENABLED" type="radio" value="1" <?php if(UC_ENABLED==1) echo 'checked';?> />启用
		<input name="UC_ENABLED" type="radio" value="0" <?php if(UC_ENABLED==0) echo 'checked';?> />停用
	</td>
	<td>是否开启会员同步登录、注册、修改资料等</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">UCenter应用ID：</td>
	<td><input name="UC_APPID" type="text" value="<?php echo UC_APPID;?>" /></td>
	<td>UCenter中心为该应用添加的ID号</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">UCenter的URL地址：</td>
	<td><input name="UC_API" type="text" value="<?php echo UC_API;?>" /></td>
	<td>例如: http://www.site.com/uc_server (最后不要加'/')</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">服务端IP：</td>
	<td><input name="UC_IP" type="text" value="<?php echo UC_IP;?>" /></td>
	<td>正常情况下留空即可。如果由于域名解析问题导致 UCenter 与该应用通信失败，请尝试设置为该应用所在服务器的 IP 地址。</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">UCenter通信密钥：</td>
	<td><input name="UC_KEY" type="text" value="<?php echo UC_KEY;?>" /></td>
	<td>与 UCenter 的通信密钥, 要与 UCenter 保持一致</td>
	</tr>	
	<tr class="odd">
	<td height="20" align="right">UCenter连接方式：</td>
	<td><select name="UC_CONNECT">
		<option value="mysql" <?php if(UC_CONNECT=='mysql') echo 'selected="selected"';?>>数据库方式(mysql)</option>
		<option value="NULL" <?php if(UC_CONNECT=='NULL') echo 'selected="selected"';?>>接口方式(fsockopen)</option>
	</select></td>
	<td></td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">UCenter数据库服务器：</td>
	<td><input name="UC_DBHOST" type="text" value="<?php echo UC_DBHOST;?>" /></td>
	<td>默认:localhost, 如果 MySQL 端口不是默认的 3306，请填写如下形式：127.0.0.1:6033</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">数据库用户名：</td>
	<td><input name="UC_DBUSER" type="text" value="<?php echo UC_DBUSER;?>" /></td>
	<td>登录uc服务端的数据库用户名</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">数据库密码：</td>
	<td><input name="UC_DBPW" type="text" value="<?php echo UC_DBPW;?>" /></td>
	<td>登录uc服务端数据库使用的密码</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">数据库名：</td>
	<td><input name="UC_DBNAME" type="text" value="<?php echo UC_DBNAME;?>" /></td>
	<td>登录uc服务端的数据库名称</td>
	</tr>
	<tr class="odd">
	<td height="20" align="right">数据库表前缀：</td>
	<td><input name="UC_DBTABLEPRE" type="text" value="<?php echo UC_DBTABLEPRE;?>" /></td>
	<td>uc服务端使用的数据库表前缀,一不般为 uc_</td>
	</tr>
	<tr class="odd">
	<td height="20">&nbsp;</td>
	<td><input type="submit" name="sub" value="提 交" class="submit" /></td>
	<td></td>
	</tr>
	</form>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">&nbsp;</td>
	</tr>
</table>  
</body>
</html>
